//package snippet;
//
//public class Snippet {
//	SELECT
//		a.*,
//		IFNULL( b.PKGS_NUM, 0 ) RETURN_PKGS_NUM,
//		IFNULL( b.AEWR, 0 ) RETURN_AEWR 
//	FROM
//		(
//	SELECT
//		woh.WO_ID,
//		woh.WO_NO,
//		woh.PAY_WAY,
//		DATE_FORMAT( woh.OUT_DATE, '%Y-%m-%d %T' ) OUT_DATE,
//		woh.RECEIVER_NAME,
//		woh.RECEIVER_TEL,
//		CONCAT(
//		IFNULL( woh.RECEIVER_STATE, '' ),
//		IFNULL( woh.RECEIVER_CITY, '' ),
//		IFNULL( woh.RECEIVER_DISTRICT, '' ),
//		IFNULL( woh.RECEIVER_ADDRESS, '' ) 
//		) AS RECEIVER_ADDRESS,
//		woh.STATUSNAME,
//		-- woh.RETURN_PKGS_NUM,
//	-- woh.RETURN_AEWR,
//		da.ACCOUNTS_NAME,
//		da.ACCOUNTS_CODE,
//		( SELECT CODE_NAME FROM D_SYSTEM_CODE ds WHERE ds.CODE_ID = woh.WO_TYPE ) AS WO_TYPE,
//		( SELECT DC_NAME FROM D_DELIVERY_COMPANY ddc WHERE ddc.DC_ID = woh.SUPPLIER_ID ) AS DC_NAME,
//		( SELECT SUPPLIER_NAME FROM D_SUPPLIER_MESSAGE dsm WHERE dsm.SUPPLIER_ID = woh.VENDOR_ID ) AS SUPPLIER_NAME,
//		dww.WAREHOUSE_NAME,
//		woi.GOODS_ID,
//		woi.REMARK,
//		IFNULL( woi.INTEGER_NUM, 0 ) AS OUTWAREHOUSE_SUM_BOX,
//		IFNULL( woi.REMAINDER_NUM, 0 ) AS OUTWAREHOUSE_SUM_CASE,
//		IFNULL( woi.INTEGER_NUM, 0 ) * IFNULL( woi.`INTEGER_PRICE`, 0 ) AS SALES_WHOLE_PRICE,
//		IFNULL( woi.REMAINDER_NUM, 0 ) * IFNULL( woi.`SALES_PRICE`, 0 ) AS SALES_PRICE,
//		IFNULL( woi.INTEGER_NUM, 0 ) * IFNULL( woi.`INTEGER_PRICE`, 0 ) + IFNULL( woi.REMAINDER_NUM, 0 ) * IFNULL( woi.`SALES_PRICE`, 0 ) AS TOTAL_PRICE,
//		dgi.GOODS_NAME,
//		dgi.GOODS_BARCODE,
//		dgi.SKU_CODE,
//		dgi.GOODS_DESC,
//		dgi.SKU_NUM,
//		woh.BILL_NO,
//		dgi.GOODS_PRICE,
//		dgi.SKU_VOLUME AS SKU_VOLUME,
//		woi.INTEGER_PRICE,
//		woi.REAL_WEIGHT,
//		woi.SALES_PRICE REMAINDER_PRICE,
//		dsc.CODE_NAME AS PACKAGE_TYPE 
//	FROM
//		(
//	SELECT
//		GROUP_CONCAT( whb.BILL_NO ) AS BILL_NO,
//		s.* 
//	FROM
//		(
//	SELECT
//		wo.`WO_ID`,
//		wo.`WO_NO`,
//		wo.`OUT_DATE`,
//		wo.`RECEIVER_NAME`,
//		wo.`RECEIVER_TEL`,
//		wo.`RECEIVER_STATE`,
//		wo.`RECEIVER_CITY`,
//		wo.`RECEIVER_DISTRICT`,
//		wo.`RECEIVER_ADDRESS`,
//		wo.`WO_TYPE`,
//		wo.`WAREHOUSE_ID`,
//		wo.`ACCOUNTS_ID`,
//		wo.`SUPPLIER_ID`,
//		wo.`VENDOR_ID`,
//		(
//	CASE
//		
//		WHEN wo.PAY_WAY = '1' THEN
//		'支付宝' 
//		WHEN wo.PAY_WAY = '2' THEN
//		'微信支付' 
//		WHEN wo.PAY_WAY = '3' THEN
//		'银联支付' 
//		WHEN wo.PAY_WAY = '4' THEN
//		'货到付款' 
//		WHEN wo.PAY_WAY = '5' THEN
//		'余额支付' 
//		WHEN wo.PAY_WAY = '6' THEN
//		'支付宝DLB' 
//		WHEN wo.PAY_WAY = '7' THEN
//		'微信支付DLB' ELSE '线下支付' 
//	END 
//		) AS PAY_WAY,
//		F_GET_STATUS_Name ( wo.STATUS ) AS STATUSNAME 
//	FROM
//		WO_HEADER wo 
//	WHERE
//		wo.B_ENABLED = '1' 
//		AND wo.IS_CONTAIN_GROUP_GOODS = '0' 
//		AND ( wo.STATUS >= 21000 AND wo.STATUS != '98000' ) 
//		AND wo.`WAREHOUSE_ID` = '36fb8d93b0ea4cb094d624d87448ac9e'
//		AND wo.COMPANY_ID ='02fe3b02bd5e427fbcb4e73bf218b075'
//		AND wo.OUT_DATE >='2018-05-31'
//		AND wo.OUT_DATE < DATE_ADD( '2018-05-31', INTERVAL 1 DAY ) 
//		) s
//		LEFT JOIN WO_HEADER_BILL whb ON s.WO_ID = whb.ORDER_ID 
//		AND whb.B_ENABLED = '1' 
//	GROUP BY
//		s.WO_ID 
//		) woh,
//		WO_ITEMS woi,
//		D_GOODS_INFO dgi,
//		D_ACCOUNTS da,
//		D_WH_WAREHOUSE dww,
//		D_SYSTEM_CODE dsc 
//	WHERE
//		dww.B_ENABLED = '1' 
//		AND woi.B_ENABLED = '1' 
//		AND dgi.B_ENABLED = '1' 
//		AND da.B_ENABLED = '1' 
//		AND dsc.B_ENABLED = '1' 
//		AND woh.WAREHOUSE_ID = dww.WAREHOUSE_ID 
//		AND woh.ACCOUNTS_ID = da.ACCOUNTS_ID 
//		AND woi.GOODS_ID = dgi.GOODS_ID 
//		AND dgi.PACKAGE_TYPE = dsc.CODE_ID 
//		AND woh.WO_ID = woi.WO_ID 
//	ORDER BY
//		woh.OUT_DATE ASC,
//		woh.WO_NO 
//		) a
//		LEFT JOIN (
//		SELECT
//			wh.`WO_ID`,
//			wii.`GOODS_ID`,
//			wii.`PKGS_NUM`,
//			wii.`AEWR`,
//			wii.`SUM_PKGS_NUM` 
//		FROM
//			wi_header wh,
//			wi_items wii 
//		WHERE
//			wii.`B_ENABLED` = '1' 
//			AND wh.`WI_ID` = wii.`WI_ID` 
//			AND wh.`COMPANY_ID` = '02fe3b02bd5e427fbcb4e73bf218b075' 
//		) b ON a.wo_id = b.wo_id 
//	AND a.goods_id = b.goods_id
//}
//
